const { LOADIPHLPAPI } = require("dns");
const fs = require("fs");
const { buffer } = require("stream/consumers");

// 创建可写流（覆盖写入）
// let ws = fs.createWriteStream("./1.txt", "utf-8");
// ws.write("1111111999111");
// ws.end();

// 创建可读流
let rs = fs.createReadStream("./1.txt", "utf-8");
// 注册监听器（数据传输，结束，异常）
let data = "";
rs.on("data", (chunk) => {
  data += chunk;
});

rs.on("end", () => {
  
});

rs.on("error", (err) => {
  console.log(err);
});


// 管道连接pipe（复制）
let copy = fs.createWriteStream("./2.txt","utf-8")
rs.pipe(copy);


